Applied modified patch from maemo-gtk which makes separators more
authorMichael Natterer <mitch@imendio.com>
Fri, 3 Mar 2006 12:38:42 +0000 (12:38 +0000)
committerMichael Natterer <mitch@src.gnome.org>
Fri, 3 Mar 2006 12:38:42 +0000 (12:38 +0000)
2006-03-03  Michael Natterer  <mitch@imendio.com>

Applied modified patch from maemo-gtk which makes separators more
themeable. Fixes bug #332022.

* gtk/gtkwidget.c: added style properties "wide-separators",
"separator-width" and "separator-height".

* gtk/gtkhseparator.c
* gtk/gtkvseparator.c
* gtk/gtkmenuitem.c
* gtk/gtktoolbar.c: honor the new settings and paint separators
using gtk_paint_box() if wide-separators is true.

ChangeLog
ChangeLog.pre-2-10
gtk/gtkhseparator.c
gtk/gtkmenuitem.c
gtk/gtktoolbar.c
gtk/gtkvseparator.c
gtk/gtkwidget.c

index 6f808f240bbe316eb7b0c3fc988374a5b0d0560b..bac6b6b83633ae75f153f6739fa432637a100c71 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2006-03-03  Michael Natterer  <mitch@imendio.com>
+
+       Applied modified patch from maemo-gtk which makes separators more
+       themeable. Fixes bug #332022.
+
+       * gtk/gtkwidget.c: added style properties "wide-separators",
+       "separator-width" and "separator-height".
+
+       * gtk/gtkhseparator.c
+       * gtk/gtkvseparator.c
+       * gtk/gtkmenuitem.c
+       * gtk/gtktoolbar.c: honor the new settings and paint separators
+       using gtk_paint_box() if wide-separators is true.
+
 2006-03-02  Dom Lachowicz <cinamod@hotmail.com>
 
        * modules/engines/ms-windows/msw_style.c: Fix combobox theming
index 6f808f240bbe316eb7b0c3fc988374a5b0d0560b..bac6b6b83633ae75f153f6739fa432637a100c71 100644 (file)
@@ -1,3 +1,17 @@
+2006-03-03  Michael Natterer  <mitch@imendio.com>
+
+       Applied modified patch from maemo-gtk which makes separators more
+       themeable. Fixes bug #332022.
+
+       * gtk/gtkwidget.c: added style properties "wide-separators",
+       "separator-width" and "separator-height".
+
+       * gtk/gtkhseparator.c
+       * gtk/gtkvseparator.c
+       * gtk/gtkmenuitem.c
+       * gtk/gtktoolbar.c: honor the new settings and paint separators
+       using gtk_paint_box() if wide-separators is true.
+
 2006-03-02  Dom Lachowicz <cinamod@hotmail.com>
 
        * modules/engines/ms-windows/msw_style.c: Fix combobox theming
index 80b6a991f1480584552b360617ec82d5b0325f06..cc6c4f8a1b9e5f758d93718855a935d9ffa712e4 100644 (file)
 #include "gtkalias.h"
 
 
-static void gtk_hseparator_class_init (GtkHSeparatorClass *klass);
-static void gtk_hseparator_init       (GtkHSeparator      *hseparator);
-static gint gtk_hseparator_expose     (GtkWidget          *widget,
-                                      GdkEventExpose     *event);
+static void gtk_hseparator_class_init   (GtkHSeparatorClass *klass);
+static void gtk_hseparator_init         (GtkHSeparator      *hseparator);
+static void gtk_hseparator_size_request (GtkWidget          *widget,
+                                         GtkRequisition     *requisition);
+static gint gtk_hseparator_expose       (GtkWidget          *widget,
+                                         GdkEventExpose     *event);
 
 
 GType
@@ -71,6 +73,7 @@ gtk_hseparator_class_init (GtkHSeparatorClass *class)
 
   widget_class = (GtkWidgetClass*) class;
 
+  widget_class->size_request = gtk_hseparator_size_request;
   widget_class->expose_event = gtk_hseparator_expose;
 }
 
@@ -87,18 +90,56 @@ gtk_hseparator_new (void)
   return g_object_new (GTK_TYPE_HSEPARATOR, NULL);
 }
 
+static void
+gtk_hseparator_size_request (GtkWidget      *widget,
+                             GtkRequisition *requisition)
+{
+  gboolean wide_separators;
+  gint     separator_height;
+
+  gtk_widget_style_get (widget,
+                        "wide-separators",  &wide_separators,
+                        "separator-height", &separator_height,
+                        NULL);
+
+  if (wide_separators)
+    requisition->height = separator_height;
+  else
+    requisition->height = widget->style->ythickness;
+}
 
 static gint
 gtk_hseparator_expose (GtkWidget      *widget,
                       GdkEventExpose *event)
 {
   if (GTK_WIDGET_DRAWABLE (widget))
-    gtk_paint_hline (widget->style, widget->window, GTK_WIDGET_STATE (widget),
-                    &event->area, widget, "hseparator",
-                    widget->allocation.x,
-                    widget->allocation.x + widget->allocation.width - 1,
-                    widget->allocation.y + (widget->allocation.height -
-                                            widget->style->ythickness) / 2);
+    {
+      gboolean wide_separators;
+      gint     separator_height;
+
+      gtk_widget_style_get (widget,
+                            "wide-separators",  &wide_separators,
+                            "separator-height", &separator_height,
+                            NULL);
+
+      if (wide_separators)
+        gtk_paint_box (widget->style, widget->window,
+                       GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
+                       &event->area, widget, "hseparator",
+                       widget->allocation.x,
+                       widget->allocation.y + (widget->allocation.height -
+                                               separator_height) / 2,
+                       widget->allocation.width,
+                       separator_height);
+      else
+        gtk_paint_hline (widget->style, widget->window,
+                         GTK_WIDGET_STATE (widget),
+                         &event->area, widget, "hseparator",
+                         widget->allocation.x,
+                         widget->allocation.x + widget->allocation.width - 1,
+                         widget->allocation.y + (widget->allocation.height -
+                                                 widget->style->ythickness) / 2);
+    }
 
   return FALSE;
 }
index 28e8db634940d3c8cc3785d35d2c043d8c99cd39..b58e13612ecf5fe5d542d967a4e8a3f9b3fabd7d 100644 (file)
@@ -559,10 +559,20 @@ gtk_menu_item_size_request (GtkWidget      *widget,
          requisition->width = MAX (requisition->width, get_minimum_width (widget));
        }
     }
-  else
+  else /* separator item */
     {
-      /* separator item */
-      requisition->height += 4;
+      gboolean wide_separators;
+      gint     separator_height;
+
+      gtk_widget_style_get (widget,
+                            "wide-separators",  &wide_separators,
+                            "separator-height", &separator_height,
+                            NULL);
+
+      if (wide_separators)
+        requisition->height += separator_height + widget->style->ythickness;
+      else
+        requisition->height += widget->style->ythickness * 2;
     }
 
   accel_width = 0;
@@ -824,18 +834,34 @@ gtk_menu_item_paint (GtkWidget    *widget,
        }
       else if (!GTK_BIN (menu_item)->child)
        {
-         guint horizontal_padding;
+          gboolean wide_separators;
+          gint     separator_height;
+         guint    horizontal_padding;
 
          gtk_widget_style_get (widget,
-                               "horizontal-padding", &horizontal_padding,
-                               NULL);
-         
-         gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL,
-                          area, widget, "menuitem",
-                          widget->allocation.x + horizontal_padding + widget->style->xthickness,
-                          widget->allocation.x + widget->allocation.width - horizontal_padding - widget->style->xthickness - 1,
-                          widget->allocation.y + (widget->allocation.height -
-                                                  widget->style->ythickness) / 2);
+                                "wide-separators",    &wide_separators,
+                                "separator-height",   &separator_height,
+                                "horizontal-padding", &horizontal_padding,
+                                NULL);
+
+          if (wide_separators)
+            gtk_paint_box (widget->style, widget->window,
+                           GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
+                           area, widget, "hseparator",
+                           widget->allocation.x + horizontal_padding + widget->style->xthickness,
+                           widget->allocation.y + (widget->allocation.height -
+                                                   separator_height -
+                                                   widget->style->ythickness) / 2,
+                           widget->allocation.width -
+                           2 * (horizontal_padding + widget->style->xthickness),
+                           separator_height);
+          else
+            gtk_paint_hline (widget->style, widget->window,
+                             GTK_STATE_NORMAL, area, widget, "menuitem",
+                             widget->allocation.x + horizontal_padding + widget->style->xthickness,
+                             widget->allocation.x + widget->allocation.width - horizontal_padding - widget->style->xthickness - 1,
+                             widget->allocation.y + (widget->allocation.height -
+                                                     widget->style->ythickness) / 2);
        }
     }
 }
index 29196215ee1a2f67ca1d580573c02d032178ce6e..09146a445ca8961640c1531b4480624bc1fbd605 100644 (file)
@@ -4852,21 +4852,55 @@ _gtk_toolbar_paint_space_line (GtkWidget       *widget,
 
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
-      gtk_paint_vline (widget->style, widget->window,
-                      GTK_WIDGET_STATE (widget), area, widget,
-                      "toolbar",
-                      allocation->y + allocation->height * start_fraction,
-                      allocation->y + allocation->height * end_fraction,
-                      allocation->x + (allocation->width - widget->style->xthickness) / 2);
+      gboolean wide_separators;
+      gint     separator_width;
+
+      gtk_widget_style_get (widget,
+                            "wide-separators", &wide_separators,
+                            "separator-width", &separator_width,
+                            NULL);
+
+      if (wide_separators)
+        gtk_paint_box (widget->style, widget->window,
+                       GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
+                       area, widget, "vseparator",
+                       allocation->x + (allocation->width - separator_width) / 2,
+                       allocation->y + allocation->height * start_fraction,
+                       separator_width,
+                       allocation->height * (end_fraction - start_fraction));
+      else
+        gtk_paint_vline (widget->style, widget->window,
+                         GTK_WIDGET_STATE (widget), area, widget,
+                         "toolbar",
+                         allocation->y + allocation->height * start_fraction,
+                         allocation->y + allocation->height * end_fraction,
+                         allocation->x + (allocation->width - widget->style->xthickness) / 2);
     }
   else
     {
-      gtk_paint_hline (widget->style, widget->window,
-                      GTK_WIDGET_STATE (widget), area, widget,
-                      "toolbar",
-                      allocation->x + allocation->width * start_fraction,
-                      allocation->x + allocation->width * end_fraction,
-                      allocation->y + (allocation->height - widget->style->ythickness) / 2);
+      gboolean wide_separators;
+      gint     separator_height;
+
+      gtk_widget_style_get (widget,
+                            "wide-separators",  &wide_separators,
+                            "separator-height", &separator_height,
+                            NULL);
+
+      if (wide_separators)
+        gtk_paint_box (widget->style, widget->window,
+                       GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
+                       area, widget, "hseparator",
+                       allocation->x + allocation->width * start_fraction,
+                       allocation->y + (allocation->height - separator_height) / 2,
+                       allocation->width * (end_fraction - start_fraction),
+                       separator_height);
+      else
+        gtk_paint_hline (widget->style, widget->window,
+                         GTK_WIDGET_STATE (widget), area, widget,
+                         "toolbar",
+                         allocation->x + allocation->width * start_fraction,
+                         allocation->x + allocation->width * end_fraction,
+                         allocation->y + (allocation->height - widget->style->ythickness) / 2);
     }
 }
 
index bbf517780d6e24f6226bef5d62365b305fbbb109..eca00ef48b668f1b048d5f26f0b4c18ed70668ec 100644 (file)
 #include "gtkalias.h"
 
 
-static void gtk_vseparator_class_init (GtkVSeparatorClass *klass);
-static void gtk_vseparator_init       (GtkVSeparator      *vseparator);
-static gint gtk_vseparator_expose     (GtkWidget          *widget,
-                                      GdkEventExpose     *event);
+static void gtk_vseparator_class_init   (GtkVSeparatorClass *klass);
+static void gtk_vseparator_init         (GtkVSeparator      *vseparator);
+static void gtk_vseparator_size_request (GtkWidget          *widget,
+                                         GtkRequisition     *requisition);
+static gint gtk_vseparator_expose       (GtkWidget          *widget,
+                                         GdkEventExpose     *event);
 
 
 GType
@@ -71,6 +73,7 @@ gtk_vseparator_class_init (GtkVSeparatorClass *klass)
 
   widget_class = (GtkWidgetClass*) klass;
 
+  widget_class->size_request = gtk_vseparator_size_request;
   widget_class->expose_event = gtk_vseparator_expose;
 }
 
@@ -87,18 +90,56 @@ gtk_vseparator_new (void)
   return g_object_new (GTK_TYPE_VSEPARATOR, NULL);
 }
 
+static void
+gtk_vseparator_size_request (GtkWidget      *widget,
+                             GtkRequisition *requisition)
+{
+  gboolean wide_separators;
+  gint     separator_width;
+
+  gtk_widget_style_get (widget,
+                        "wide-separators", &wide_separators,
+                        "separator-width", &separator_width,
+                        NULL);
+
+  if (wide_separators)
+    requisition->height = separator_width;
+  else
+    requisition->height = widget->style->xthickness;
+}
 
 static gint
 gtk_vseparator_expose (GtkWidget      *widget,
                       GdkEventExpose *event)
 {
   if (GTK_WIDGET_DRAWABLE (widget))
-    gtk_paint_vline (widget->style, widget->window, GTK_WIDGET_STATE (widget),
-                    &event->area, widget, "vseparator",
-                    widget->allocation.y,
-                    widget->allocation.y + widget->allocation.height - 1,
-                    widget->allocation.x + (widget->allocation.width -
-                                            widget->style->xthickness) / 2);
+    {
+      gboolean wide_separators;
+      gint     separator_width;
+
+      gtk_widget_style_get (widget,
+                            "wide-separators", &wide_separators,
+                            "separator-width", &separator_width,
+                            NULL);
+
+      if (wide_separators)
+        gtk_paint_box (widget->style, widget->window,
+                       GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
+                       &event->area, widget, "vseparator",
+                       widget->allocation.x + (widget->allocation.width -
+                                               separator_width) / 2,
+                       widget->allocation.y,
+                       separator_width,
+                       widget->allocation.height);
+      else
+        gtk_paint_vline (widget->style, widget->window,
+                         GTK_WIDGET_STATE (widget),
+                         &event->area, widget, "vseparator",
+                         widget->allocation.y,
+                         widget->allocation.y + widget->allocation.height - 1,
+                         widget->allocation.x + (widget->allocation.width -
+                                                 widget->style->xthickness) / 2);
+    }
 
   return FALSE;
 }
index 187028af15f49c8845da29df10807e5e7ad2e047..2872df9327d0996a4219b6f581b7d554e725592f 100644 (file)
@@ -1515,7 +1515,28 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                               P_("Visited Link Color"),
                                                               P_("Color of visited links"),
                                                               GDK_TYPE_COLOR,
-                                                              GTK_PARAM_READABLE));                                                           
+                                                              GTK_PARAM_READABLE));
+
+  gtk_widget_class_install_style_property (klass,
+                                           g_param_spec_boolean ("wide-separators",
+                                                                 P_("Wide Separators"),
+                                                                 P_("Whether separators have configurable width and should be drawn using a box instead of a line"),
+                                                                 FALSE,
+                                                                 GTK_PARAM_READABLE));
+
+  gtk_widget_class_install_style_property (klass,
+                                           g_param_spec_int ("separator-width",
+                                                             P_("Separator Width"),
+                                                             P_("The width of separators if wide-separators is TRUE"),
+                                                             0, 64, 0,
+                                                             GTK_PARAM_READABLE));
+
+  gtk_widget_class_install_style_property (klass,
+                                           g_param_spec_int ("separator-height",
+                                                             P_("Separator Height"),
+                                                             P_("The height of separators if wide-separators is TRUE"),
+                                                             0, 64, 0,
+                                                             GTK_PARAM_READABLE));
 }
 
 static void